<?php
// No direct access to this file
defined('_JEXEC') or die;
 
// import the list field type
jimport('joomla.html.html');
jimport('joomla.form.formfield');
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
 
/**
 * NGMenu Form Field class for the NGMenu component
 */
class JFormFieldCssFile extends JFormFieldList
{
	/**
	 * The field type.
	 *
	 * @var		string
	 */
	protected $type = 'CssFile';
 
//	public function getLabel() {
//	}
 
	public function getInput() {
	//build the list from all css files
		$css_relpath = 'modules'.DS.'mod_ngmenu'.DS.'mod_ngmenu'.DS.'css';
		$css_path = JPATH_ROOT.DS.$css_relpath;
		$css_folder = @dir($css_path);
		$css_values = array();
		if ($css_folder) {
			while ($css_file = $css_folder->read()){
				if ($css_file != "." && $css_file != ".." && $css_file != "CVS" && is_file("$css_path/$css_file")){
					$css_relpath = str_replace( '\\', '/', $css_relpath );
					$css_values[] = JHtml::_('select.option', "/$css_relpath/$css_file", $css_file);
				}
			}
			$css_folder->close();
		}
		sort($css_values);

		return JHtml::_('select.genericlist', $css_values, $this->name, null, 'value', 'text', $this->value);
	}
}
